function esp_cmake_flash() {
    if [ ! -n "$1" ]; then
        idf.py -b 921600 flash
    else
        if [ "$1" = "a" ]; then
            # for sp in /dev/ttyUSB*
            # do {
            #     if [ $sp == "/dev/ttyUSB*" ]; then
            #         ESP_LOGW "No /dev/ttyUSB* Device!"
            #         exit
            #     fi
            # }
            # done

            for sp in /dev/ttyUSB*
            do {
                one_sp=${sp#*USB}
                idf.py -p /dev/ttyUSB$one_sp -b 921600 flash
            } &
            done
            wait
        else
            idf.py -p /dev/ttyUSB$1 -b 921600 flash
        fi
    fi
}

function esp_cmake_monitor() {
    if [ ! -n "$1" ]; then
        idf.py monitor
    else
        idf.py -p /dev/ttyUSB$1 monitor
    fi
}

function esp_cmake_flash_monitor() {
    if [ ! -n "$1" ]; then
        idf.py flash monitor
    else
        idf.py -p /dev/ttyUSB$1 -b 921600 flash monitor
    fi
}

function esp_cmake_erase_flash() {
    if [ ! -n "$1" ]; then
        idf.py erase_flash
    else
        idf.py -p /dev/ttyUSB$1 erase_flash
    fi
}
